#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<functional>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <exception>
#include <iomanip>
#include <memory>
#include <sstream>

using namespace std;

bool check(int x, int y, int m, int n, vector<vector<char>>& room)
{
	return x >= 0 && x < m && y >= 0 && y < n && room[x][y] == '.';
}

int main(int argc, char** argv)
{
	//freopen("in.txt", "r", stdin);
	int m, n;
	while (cin >> m >> n)
	{
		vector<vector<char>> room(m, vector<char>(n));
		string row;
		int sx, sy;
		for (int i = 0; i < m; ++i)
		{
			cin >> row;
			for (int j = 0; j < n; ++j)
			{
				room[i][j] = row[j];
				if (room[i][j] == '@')
				{
					sx = i;
					sy = j;
				}
			}
		}

		vector<pair<int, int>> cur;
		cur.emplace_back(sx, sy);
		int count = 1;
		room[sx][sy] = ' ';
		while (!cur.empty())
		{
			vector<pair<int, int>> next;
			for (auto& pr : cur)
			{
				int x = pr.first, y = pr.second;
				if (check(x - 1, y, m, n, room))
				{
					++count;
					room[x - 1][y] = ' ';
					next.emplace_back(x - 1, y);
				}
				if (check(x + 1, y, m, n, room))
				{
					++count;
					room[x + 1][y] = ' ';
					next.emplace_back(x + 1, y);
				}
				if (check(x, y - 1, m, n, room))
				{
					++count;
					room[x][y - 1] = ' ';
					next.emplace_back(x, y - 1);
				}
				if (check(x, y + 1, m, n, room))
				{
					++count;
					room[x][y + 1] = ' ';
					next.emplace_back(x, y + 1);
				}
			}
			cur = next;
		}

		cout << count << endl;
	}

	return 0;
}